//
// Custom-checkbox.scss
//

.checkbox {
  label {
    position: relative;
    display: inline-block;
    padding-left: 8px;
    margin-bottom: 0;
    font-weight: normal;
    &::before {
      position: absolute;
      top: 2px;
      left: 0;
      display: inline-block;
      width: 18px;
      height: 18px;
      margin-left: -18px;
      content: '';
      background-color: $gray-300;
      border: 2px solid $gray-300;
      border-radius: 3px;
      outline: none !important;
      transition: 0.3s ease-in-out;
    }
    &::after {
      position: absolute;
      top: 0;
      left: 0;
      display: inline-block;
      width: 18px;
      height: 18px;
      padding-top: 2px;
      padding-left: 3px;
      margin-left: -18px;
      font-size: 11px;
      color: $gray-700;
    }
  }
  input[type='checkbox'] {
    z-index: 1;
    cursor: pointer;
    outline: none !important;
    opacity: 0;
    &:disabled + label {
      opacity: 0.65;
    }
  }
  input[type='checkbox']:focus + label {
    &::before {
      outline: none;
      outline-offset: -2px;
    }
  }
  input[type='checkbox']:checked + label {
    &::after {
      position: absolute;
      top: 6px;
      left: 7px;
      display: table;
      width: 4px;
      height: 8px;
      content: '';
      border: 2px solid $gray-700;
      border-top-width: 0;
      border-left-width: 0;
      -webkit-transform: rotate(45deg);
      -ms-transform: rotate(45deg);
      -o-transform: rotate(45deg);
      transform: rotate(45deg);
    }
  }
  input[type='checkbox']:disabled + label {
    &::before {
      cursor: not-allowed;
      background-color: $light;
    }
  }
}

.checkbox.checkbox-circle {
  label {
    &::before {
      border-radius: 50%;
    }
  }
}

.checkbox.checkbox-inline {
  margin-top: 0;
}

.checkbox.checkbox-single {
  input {
    position: absolute;
    width: 18px;
    height: 18px;
  }
  label {
    width: 18px;
    height: 18px;
    &::before {
      margin-left: 0;
    }
    &::after {
      margin-left: 0;
    }
  }
}

@each $color, $value in $theme-colors {
  .checkbox-#{$color} {
    input[type='checkbox']:checked + label {
      &::before {
        background-color: $value;
        border-color: $value;
      }
      &::after {
        border-color: $white;
      }
    }
  }
}
